/**
 * Bestpay.com.cn Inc.
 * Copyright (c) 2011-2018 All Rights Reserved.
 */
package com.sgzn.sgpay.model.response;

import com.google.common.base.Objects;

import java.io.Serializable;

/**
 * 公共响应类
 * @author zhongzhongyong
 * @version Id: CommonResponse.java, v 0.1 2018/4/1 16:17 zhongzhongyong Exp $$
 */
public class CommonResponse<T> implements Serializable {
    
    private static final long serialVersionUID = -6772096631828867255L;
    private T result;
    private String errorCode;
    private String errorMsg;

    public CommonResponse() {
    }

    public CommonResponse(T result) {
        this.result = result;
    }

    public CommonResponse(String errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public T getResult() {
        return this.result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public String getErrorCode() {
        return this.errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return this.errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public boolean equals(Object o) {
        if(this == o) {
            return true;
        } else if(o != null && this.getClass() == o.getClass()) {
            CommonResponse response = (CommonResponse)o;
            return !this.errorCode.equals(response.errorCode)?false:(!this.errorMsg.equals(response.errorMsg)?false:this.result.equals(response.result));
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        byte result1 = 1;
        int result11 = 31 * result1 + this.result.hashCode();
        result11 = 31 * result11 + this.errorCode.hashCode();
        result11 = 31 * result11 + this.errorMsg.hashCode();
        return result11;
    }

    @Override
    public String toString() {
        return Objects.toStringHelper(this).add("result", this.result).add("errorCode", this.errorCode).add("errorMsg", this.errorMsg).omitNullValues().toString();
    }
}
